package models

import (
	"time"

	"github.com/astaxie/beego/orm"
)

type Orders struct {
	Id         int
	User       *User         `orm:"rel(fk)" description:"用户"`
	CreateTime time.Time     `orm:"orm:"auto_now_add;type(datetime)" description:"创建时间"`
	IsPay      bool          `description:"是否付款"`
	Status     int           `orm:"default(0)" description:"订单状态 1未付款  2已付款  3未发货  4已发货 6配送中  7已签收  8已评价 9已取消"`
	FinishTime time.Time     `orm:"type(datetime)" description:"订单完成时间"`
	OrderItem  []*OrderItems `orm:"reverse(many)" description:"订单商品"`
}

type OrderItems struct {
	Id        int
	ProductId int     `orm:"ref('product')"`
	Number    int     `description:"商品数量"`
	Order     *Orders `orm:"rel(fk)"`
}

func init() {
	orm.RegisterModel(new(OrderItems))
	orm.RegisterModel(new(Orders))
}
